export default {
  inject: ['root'],
  props: {
    dialogVisible: Boolean
  },
  data() {
    return {
      formModel: {}
    }
  },
  methods: {
    handleClose() {
      console.log('close dialog')
      this.$emit('close-dialog')
    },
    handleUpdate() {
      console.log('model update')
      const { getSelected, executeCommand, update } = this.root.propsAPI
      const { formModel } = this
      setTimeout(() => {
        const item = getSelected()[0]
        if (!item) {
          return
        }
        formModel.executed = false
        executeCommand(() => {
          update(item, formModel)
        })
        this.$emit('close-dialog')
      }, 0)
    }
  }
}
